/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Main.java
 *
 * Created on 20-07-2012, 11:17:33
 */

package frame;

import kbcquiz.App;

public class Main extends javax.swing.JFrame {

    /** Creates new form Main */
    public Main() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        btnConfiguration = new javax.swing.JButton();
        btnPlaynow = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jFile = new javax.swing.JMenu();
        jNewgame = new javax.swing.JMenuItem();
        jManagement = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        jExit = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jCheckBoxMenuItem1 = new javax.swing.JCheckBoxMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jGamerule = new javax.swing.JMenuItem();
        jAbout = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Main Frame");

        jPanel1.setName("jPanel1"); // NOI18N

        jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 36)); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/kbc_quiz_game.png"))); // NOI18N
        jLabel1.setText(" KBC Quiz Game");
        jLabel1.setName("jLabel1"); // NOI18N

        btnConfiguration.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/configuration.png"))); // NOI18N
        btnConfiguration.setText(" Configuration");
        btnConfiguration.setName("btnConfiguration"); // NOI18N
        btnConfiguration.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnConfigurationActionPerformed(evt);
            }
        });

        btnPlaynow.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/play_now.png"))); // NOI18N
        btnPlaynow.setText("  Play now");
        btnPlaynow.setName("btnPlaynow"); // NOI18N
        btnPlaynow.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPlaynowActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 362, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addComponent(btnConfiguration)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnPlaynow, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(24, 24, 24))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnConfiguration)
                    .addComponent(btnPlaynow, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(48, Short.MAX_VALUE))
        );

        jMenuBar1.setName("jMenuBar1"); // NOI18N

        jFile.setText("File");
        jFile.setName("jFile"); // NOI18N

        jNewgame.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK));
        jNewgame.setText("New game");
        jNewgame.setName("jNewgame");
        jNewgame.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jNewgameActionPerformed(evt);
            }
        });
        jFile.add(jNewgame);

        jManagement.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M, java.awt.event.InputEvent.CTRL_MASK));
        jManagement.setText("Management");
        jManagement.setName("jManagement");
        jManagement.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jManagementActionPerformed(evt);
            }
        });
        jFile.add(jManagement);

        jSeparator1.setName("jSeparator1");
        jFile.add(jSeparator1);

        jExit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.ALT_MASK));
        jExit.setText("Exit");
        jExit.setName("jExit");
        jExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jExitActionPerformed(evt);
            }
        });
        jFile.add(jExit);

        jMenuBar1.add(jFile);

        jMenu2.setText("Game");
        jMenu2.setName("jMenu2"); // NOI18N

        jCheckBoxMenuItem1.setSelected(true);
        jCheckBoxMenuItem1.setText("Time limit");
        jCheckBoxMenuItem1.setName("jCheckBoxMenuItem1");
        jMenu2.add(jCheckBoxMenuItem1);

        jMenuBar1.add(jMenu2);

        jMenu3.setText("Help");
        jMenu3.setName("jMenu3"); // NOI18N

        jGamerule.setText("Game rule");
        jGamerule.setName("jGamerule");
        jGamerule.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jGameruleActionPerformed(evt);
            }
        });
        jMenu3.add(jGamerule);

        jAbout.setText("About");
        jAbout.setName("jAbout");
        jAbout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jAboutActionPerformed(evt);
            }
        });
        jMenu3.add(jAbout);

        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jManagementActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jManagementActionPerformed
        App.switchDisplay(App.getLoginFrame());
    }//GEN-LAST:event_jManagementActionPerformed

    private void btnPlaynowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPlaynowActionPerformed
        jNewgameActionPerformed(evt);
        this.dispose();
    }//GEN-LAST:event_btnPlaynowActionPerformed

    private void jExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jExitActionPerformed
        this.dispose();
        System.exit(0);
    }//GEN-LAST:event_jExitActionPerformed

    private void jGameruleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jGameruleActionPerformed
        new GameRule().setVisible(true);
    }//GEN-LAST:event_jGameruleActionPerformed

    private void jAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jAboutActionPerformed
        new About().setVisible(true);
    }//GEN-LAST:event_jAboutActionPerformed

    private void btnConfigurationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConfigurationActionPerformed
        App.switchDisplay(App.getConfigurateFrame());
    }//GEN-LAST:event_btnConfigurationActionPerformed

    private void jNewgameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jNewgameActionPerformed
       App.switchDisplay(App.getParticipateFrame());
    }//GEN-LAST:event_jNewgameActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Main().setVisible(true);
            }
        });
    }
    
     
    private void managementItemActionPerformed(java.awt.event.ActionEvent evt) {                                               
//        if (App.IsLogin()) {
//            App.switchDisplay(App.getAdminFrame());
//        }
//        else {
            App.switchDisplay(App.getLoginFrame());
//        }
    }                
     
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnConfiguration;
    private javax.swing.JButton btnPlaynow;
    private javax.swing.JMenuItem jAbout;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1;
    private javax.swing.JMenuItem jExit;
    private javax.swing.JMenu jFile;
    private javax.swing.JMenuItem jGamerule;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenuItem jManagement;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jNewgame;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    // End of variables declaration//GEN-END:variables

}
